package leetcode.editor.cn;

//Java：赎金信
public class RansomNote {
    public static void main(String[] args) {
        Solution solution = new RansomNote().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean canConstruct(String ransomNote, String magazine) {
            int[] res = new int[26];
            if (ransomNote.length() > magazine.length()) return false;

            for (char i : magazine.toCharArray()) {
                res[i - 'a']++;
            }
            for (char j : ransomNote.toCharArray()) {
                res[j - 'a']--;
            }

            for (int i : res) {
                if (i < 0) {
                    return false;
                }
            }
            return true;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}